# -*- coding: utf-8 -*-
"""
股票信息
"""
class StockInfo:
    def __init__(self, market_code: str=1, stock_code: str="601600", name: str="创业环保", date: str="", open: float=0.0, close: float=0.0, high: float=0.0, low: float=0.0, volume: int=0, amount: float=0.0, amplitude: float=0.0, change_rate: float=0.0, change_amount: float=0.0, turnover_rate: float=0.0):
        '''
        股票信息，初始化方法

        参数:
            market_code (str): 交易所代码：1=上交所，0=深交所
            stock_code (str): 股票代码
            name (str): 股票名称
            date: str           # 日期
            open: float         # 开盘价
            close: float        # 收盘价
            high: float         # 最高价格
            low: float          # 最低价格
            volume: int         # 成交量
            amount: float       # 成交额
            amplitude: float    # 振幅
            change_rate: float  # 涨跌幅
            change_amount: float # 涨跌额
            turnover_rate: float # 换手率
        '''
        self._market_code = market_code
        self._stock_code = stock_code
        self._name = name
        self._date = date
        self._open = open
        self._close = close
        self._high = high
        self._low = low
        self._volume = volume
        self._amount = amount
        self._amplitude = amplitude
        self._change_rate = change_rate
        self._change_amount = change_amount
        self._turnover_rate = turnover_rate

    def __repr__(self) -> str:
        """返回配置的字符串表示"""
        return self.__str__()

    def __str__(self) -> str:
        """返回配置的字符串表示"""
        return f"StockInfo(交易所代码(market_code)={self._market_code}, 股票代码(stock_code)={self._stock_code}, 股票名称(name)={self._name}, 日期(date)={self._date}, 开盘价(open)={self._open}, 收盘价(close)={self._close}, 最高价(high)={self._high}, 最低价(low)={self._low}, 成交量(volume)={self._volume}, 成交额(amount)={self._amount}, 振幅(amplitude)={self._amplitude}, 涨跌幅(change_rate)={self._change_rate}, 涨跌额(change_amount)={self._change_amount}, 换手率(turnover_rate)={self._turnover_rate})"

    @property
    def market_code(self) -> str:
        """获取 交易所代码"""
        return self._market_code

    @market_code.setter
    def market_code(self, value: str) -> None:
        """设置 交易所代码（1=上交所，0=深交所）"""
        if not isinstance(value, str) or not value.strip():
            raise ValueError("交易所代码 必须是一个非空字符串")
        self._market_code = value
        
    @property
    def stock_code(self) -> str:
        """获取 股票代码"""
        return self._stock_code

    @stock_code.setter
    def stock_code(self, value: str) -> None:
        """设置 股票代码"""
        if not isinstance(value, str) or not value.strip():
            raise ValueError("股票代码 必须是一个非空字符串")
        self._stock_code = value

    @property
    def name(self) -> str:
        """获取 股票名称"""
        return self._name

    @name.setter
    def name(self, value: str) -> None:
        """设置 股票名称"""
        if not isinstance(value, str) or not value.strip():
            raise ValueError("股票名称 必须是一个非空字符串")
        self._name = value

    @property
    def date(self) -> str:
        """获取 日期"""
        return self._date

    @date.setter
    def date(self, value: str) -> None:
        """设置 日期"""
        if not isinstance(value, str) or not value.strip():
            raise ValueError("日期 必须是一个非空字符串")
        self._date = value

    @property
    def open(self) -> float:
        """获取 开盘价"""
        return self._open

    @open.setter
    def open(self, value: float) -> None:
        """设置 开盘价"""
        if not isinstance(value, (int, float)) or value < 0:
            raise ValueError("开盘价 必须是一个非负浮点数")
        self._open = value

    @property
    def close(self) -> float:
        """获取 收盘价"""
        return self._close

    @close.setter
    def close(self, value: float) -> None:
        """设置 收盘价"""
        if not isinstance(value, (int, float)) or value < 0:
            raise ValueError("收盘价 必须是一个非负浮点数")
        self._close = value

    @property
    def high(self) -> float:
        """获取 最高价"""
        return self._high

    @high.setter
    def high(self, value: float) -> None:
        """设置 最高价"""
        if not isinstance(value, (int, float)) or value < 0:
            raise ValueError("最高价 必须是一个非负浮点数")
        self._high = value

    @property
    def low(self) -> float:
        """获取 最低价"""
        return self._low

    @low.setter
    def low(self, value: float) -> None:
        """设置 最低价"""
        if not isinstance(value, (int, float)) or value < 0:
            raise ValueError("最低价 必须是一个非负浮点数")
        self._low = value

    @property
    def volume(self) -> int:
        """获取 成交量"""
        return self._volume

    @volume.setter
    def volume(self, value: int) -> None:
        """设置 成交量"""
        if not isinstance(value, int) or value < 0:
            raise ValueError("成交量 必须是一个非负整数")
        self._volume = value

    @property
    def amount(self) -> float:
        """获取 成交额"""
        return self._amount

    @amount.setter
    def amount(self, value: float) -> None:
        """设置 成交额"""
        if not isinstance(value, (int, float)) or value < 0:
            raise ValueError("成交额 必须是一个非负浮点数")
        self._amount = value

    @property
    def amplitude(self) -> float:
        """获取 振幅"""
        return self._amplitude

    @amplitude.setter
    def amplitude(self, value: float) -> None:
        """设置 振幅"""
        if not isinstance(value, (int, float)) or value < 0:
            raise ValueError("振幅 必须是一个非负浮点数")
        self._amplitude = value

    @property
    def change_rate(self) -> float:
        """获取 涨跌幅"""
        return self._change_rate

    @change_rate.setter
    def change_rate(self, value: float) -> None:
        """设置 涨跌幅"""
        if not isinstance(value, (int, float)) or value < 0:
            raise ValueError("涨跌幅 必须是一个非负浮点数")
        self._change_rate = value

    @property
    def change_amount(self) -> float:
        """获取 涨跌额"""
        return self._change_amount

    @change_amount.setter
    def change_amount(self, value: float) -> None:
        """设置 涨跌额"""
        if not isinstance(value, (int, float)) or value < 0:
            raise ValueError("涨跌额 必须是一个非负浮点数")
        self._change_amount = value

    @property
    def turnover_rate(self) -> float:
        """获取 换手率"""
        return self._turnover_rate
    
    @turnover_rate.setter
    def turnover_rate(self, value: float) -> None:
        """设置 换手率"""
        if not isinstance(value, (int, float)) or value < 0:
            raise ValueError("换手率 必须是一个非负浮点数")
        self._turnover_rate = value
